﻿define(['text!/CommonRoot/lib/common/templates/common-pagination.html'], function (template) {
    Vue.component('common-pagination', {
        template: template,
        props: {
            page: {
                type: Object,
                default: function () {
                    return {
                        maxResultCount: 10,
                        skipCount: 0
                    }
                }
            },
            total: {
                type: Number,
                default: function () { return 0; }
            }
        },
        model: {
            prop: 'page',
            event: 'change'
        },
        methods: {
            handleCurrentChange: function (val) {
                this.page.skipCount = (val - 1) * this.page.maxResultCount;
                this.$emit('change', this.page);
            },
            handleSizeChange: function (val) {
                this.page.maxResultCount = val;
                this.$emit('change', this.page);
            }
        }
    });
});